import React from 'react';
import Header from "./Header";
import Main from "./Main";
import Foot from "./Foot";

class MainIndex extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            field: null,
        }
    }

    clickFiledEvent = function (field) {
        console.log('clickFiledEvent', field);
        this.setState({
            field: field
        })
    };

    render() {
        const { field } = this.state;
        return (
            <div>
                <h1>父子通信</h1>
                <div>点击了：{field}</div>
                <Header clickField={e => this.clickFiledEvent(e)}/>
                <Main clickField={e => this.clickFiledEvent(e)}/>
                <Foot clickField={e => this.clickFiledEvent(e)}/>
            </div>
        )
    }
}
export default MainIndex